package Demo;

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

import org.apache.bcel.generic.InstructionHandle;

import java.util.ArrayList;

public class BasicBlock {
    ArrayList<InstructionHandle> instructions = new ArrayList();
    InstructionHandle lastHandle;
    int num = 0;

    public BasicBlock(InstructionHandle iH1, InstructionHandle iH2) {
        for(this.lastHandle = iH2; iH1.getNext() != iH2; iH1 = iH1.getNext()) {
            this.instructions.add(iH1);
            ++this.num;
        }

        this.instructions.add(iH1);
        ++this.num;
    }

    public InstructionHandle getLastIH() {
        int listSize = this.instructions.size();
        return listSize > 0 ? this.lastHandle.getPrev() : null;
    }

    public ArrayList getInstList() {
        return this.instructions;
    }

    public int getNumOfInstr() {
        return this.num;
    }

    public void addInst(InstructionHandle inst) {
        this.instructions.add(inst);
    }
}

